<?php
function save_news($newstitle,$newscontent,$newsdate,$userid,$newstype){
	$query="INSERT INTO news(TITLE,CONTENT,NEWSDATE,AUTHOR,NEWSTYPE) VALUES('$newstitle','$newscontent','$newsdate',$userid,$newstype)";
	mysql_query($query);
	$query="SELECT Id FROM news WHERE USERID=$userid AND CONTENT='$newscontent' ORDER BY REPORTDATE LIMIT 0,1";
	$result=mysql_query($query);
	return $result;
}
function get_news_list($userid){
	$query="SELECT * FROM news WHERE AUTHOR=$userid ORDER BY NEWSDATE DESC,Id DESC";
	$result=mysql_query($query);
	return $result;
}
function get_news_list_s($userid){
	$query="SELECT * FROM news WHERE AUTHOR=(SELECT USERGROUP FROM user WHERE USERID=$userid) AND NEWSTYPE=".GROUPMSGCODE." ORDER BY NEWSDATE DESC LIMIT 0,10";
	$result=mysql_query($query);
	return $result;
}
function check_deleting_news($titleid,$userid){
	$query="SELECT * FROM news WHERE Id=$titleid AND AUTHOR=$userid";
	$result=mysql_query($query);
	return $result;
}
function del_news($titleid){
	$query="DELETE FROM news WHERE Id=$titleid";
	mysql_query($query);
}
function get_news_index($newstype){
	$query="SELECT * FROM news WHERE NEWSTYPE=$newstype ORDER BY NEWSDATE DESC,Id DESC LIMIT 0,8";
	$result=mysql_query($query);
	return $result;
}
function get_news_detail($id){
	$query="SELECT * FROM news WHERE Id=$id";
	return mysql_query($query);
}
function get_author_right($userid){
	$query="SELECT NEWSRIGHT FROM user WHERE USERID=$userid";
	$result=mysql_query($query);
	return $result;
}
?>